/*
 * Title:        CloudScheduler Toolkit
 * Description:  a Toolkit for Modeling and Simulation of Job Scheduling and Resource Provisioning in Cloud System
 * Licence:      GPL - http://www.gnu.org/copyleft/gpl.html
 * Author:       Fuhui Wu
 *
 * Copyright (c) 2013-2014, The National University of Defense Technology, China
 */

package org.nudt.jCloud.workload;

import java.util.List;

import org.nudt.jCloud.infrastructure.SlotType;
import org.nudt.jCloud.simulation.Batch;

public class BatchJob extends Job{

	public BatchJob(double arrivalTime, List<Task> taskList, SlotType slotType,
			LogicalJob xJob) {
		super(arrivalTime, taskList, slotType, xJob);
	}

	@Override
	public Batch nextBatch(int maxSize) {
		if(maxSize<=0 || getUnScheduledTasks().size()<=0){
			return null;
		}
		Batch batch = createBatch();
		if(getUnScheduledTasks().size()<=maxSize){
			for(int i=0; i<getUnScheduledTasks().size(); ++i){
				batch.add(getUnScheduledTasks().get(i));
			}
		}else{
			for(int i=0; i<maxSize; ++i){
				batch.add(getUnScheduledTasks().get(i));
			}
		}
		return batch;
	}

	@Override
	public String getType() {
		return "BATCH";
	}

}
